package com.gomoku.backend.utils;

import io.jsonwebtoken.Claims;

public class JwtAuthentication {
    public static Integer getUserId(String token){ //static 通过类名直接调用
        int userId = -1; //表示为空
        try {
            Claims claims = JwtUtil.parseJWT(token); //这里token其实只需要前7个字符就可以
            userId = Integer.parseInt(claims.getSubject());
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
        return userId;
    }
}